package com.thread2;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

import com.thread4.CallableDe;

public class CallableTest {
	public static void main(String[] args) throws Exception {

		CallableDe callableDemo = new CallableDe();
		FutureTask<String> futureTask = new FutureTask<>(callableDemo);
		System.out.println(futureTask.isDone());
		Thread thread = new Thread(futureTask);
		thread.start();
		new Thread(new Runnable() {

			@Override
			public void run() {
				for (int i = 0; i < 100; i++) {
					System.out.println("i==" + i + this.getClass().getName());
				}

			}
		}, "main").start();
		try {
			String s = futureTask.get();
			boolean isDone = futureTask.isDone();
			System.out.println(s);
			System.out.println(isDone);
		} catch (InterruptedException e) {
			e.printStackTrace();
		} catch (ExecutionException e) {
			e.printStackTrace();
		}
	}

}
